/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package state;

import cbaServer.BankServerCBAInterface;

/**
 *
 * @author Rente
 */
public class StateContext {

    private State state;
    private StateOn onState;
    private StateOff offState;
    BankServerCBAInterface bankServerCBAInterface;

    public StateContext(BankServerCBAInterface bankServerCBAInterface) {
        onState = new StateOn();
        offState = new StateOff();
        onState.setBankServerInterface(bankServerCBAInterface);
        offState.setBankServerInterface(bankServerCBAInterface);
    }

    /**
     * @return the state
     */
    public State getState() {
        return state;
    }

    /**
     * @param state the state to set
     */
    public void setState(boolean on) {
       if(on){
        this.state = onState;
       }else {
        this.state = offState;
       }
    }

    public int fazLevantamento(String idConta, double quantia){
        return this.state.fazLevantamento(idConta, quantia);
    }
}
